

//include ("PlayScene.js");

var res = {
    bg: "img/bg.png",
    bt1: "img/bt1.png",
    bt2: "img/bt2.png",
    sushi: "img/ball.png",
    sushi_black: "img/ball_black.png",
    car: "img/hand.png"

};


var StartLayer = cc.Layer.extend({
        ctor:function() {
                this._super();
                var size = cc.winSize;
                
                /*********************************************************/
                //添加文字
                var helloLabel = new cc.LabelTTF("Just A Test!", "", 30);
                helloLabel.x = size.width / 2;
                helloLabel.y = size.height / 2 + 60;
                this.addChild(helloLabel, 1);

                /*********************************************************/
                //添加背景图片
                this.bgSprite = new cc.Sprite(res.bg);
                this.bgSprite.attr({
                        x:size.width / 2,
                        y:size.height / 2,
                });
                this.addChild(this.bgSprite, 0); 


                /*********************************************************/
                //添加按钮
                var startItem = new cc.MenuItemImage(
                        res.bt1,
                        res.bt2,
                        function() {
                                cc.log("Menu is clicked!");
                                //cc.director.replaceScene(
                                //        cc.TransitionPageTurn(1, new PlayScene(), false));
                                //cc.director.runScene(new PlayScene()); 
                                cc.director.pushScene(new PlayScene());
                        }, this);

                startItem.attr({
                        x: size.width / 2,
                        y: size.height / 2 - 20,
                        anchorX: 0.5,
                        anchorY: 0.5,
                });

                console.log(size.width);
                console.log(size.height);

                var menu = new cc.Menu(startItem);
                menu.x = 0; 
                menu.y = 0; 
                this.addChild(menu, 1);

                return true;

        }
});


var StartScene = cc.Scene.extend({
        onEnter:function() {
                this._super();
                var layer = new StartLayer();
                this.addChild(layer);
        }
});



var g_resources = [];


function onLoad ()
{
        cc.game.onStart = function()
        {
                //load resources
                cc.LoaderScene.preload(g_resources, function () {
                        cc.director.runScene(new StartScene());
                }, this);

                cc.view.setDesignResolutionSize(320, 480, cc.ResolutionPolicy.SHOW_ALL);
                cc.view.resizeWithBrowserSize(true);
        };
        cc.game.run("gameCanvas");
}

